package operation;
import book.Book;
import book.BookList;

public class Purchase implements IOperation {
    public void work(BookList bl) {
        double sum = 0;
        System.out.println("----——--欢迎光临图书商城--——-----");
        System.out.println("-----------购物清单-----------");
        for (int i = 0; i < bl.getSize(); i++) {
            Book book = bl.getBook(i);
            System.out.println(book); // Book类重写了toString方法以显示书籍信息
            sum += book.getPrice();
        }
        System.out.println("----------------------------");
        System.out.println("     你一共需要支付：" + sum + "元");
    }
}
